package com.crm.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.crm.entity.UserChecks;

public interface UserCheckRepository  extends JpaRepository<UserChecks, Integer>,JpaSpecificationExecutor<UserChecks>{

	
	
	@Query(value="select * from user_checks where user_id=?1 and check_state='已签到';", nativeQuery=true)
	UserChecks getUserChecksById_CheckState(String id);
	
	
			/**
			 * 将签到记录表中签到但未签退的状态在定时中强制签退
			 * @return
			 */
			@Query(value="update  user_checks set check_state='已签退' where check_state ='已签到' ", nativeQuery=true)
			@Transactional
			@Modifying	
			Integer reSetUser_CheckState();
}
